Skip to content

Jetpack AI: show block edit outcomes with Undo - #113317

Open
kat3samsin wants to merge 6 commits into
trunkfrom
codex/fix-forno-451-updated-undo
Open

Jetpack AI: show block edit outcomes with Undo#113317
kat3samsin wants to merge 6 commits into
trunkfrom
codex/fix-forno-451-updated-undo

Conversation

@kat3samsin

@kat3samsin kat3samsin commented Aug 5, 2026

Copy link
Copy Markdown
Contributor

Part of FORNO-451

Screenshot 2026-08-05 at 16 47 28 Screenshot 2026-08-05 at 16 48 01

Proposed Changes

  • Render only authoritative post-execution outcomes for block-edit tools: a concrete summary for applied edits and No changes needed for a true no-op.
  • Show applied edits as a green Updated status with adjacent Undo, while keeping feedback and Copy actions on the following row.
  • Give the Jetpack update-block-content client ability a restorable block snapshot and structured updated / no-changes result.
  • Require the model-facing update-block-content summary to name concrete spelling or grammar corrections, follow the request language, and report when no changes were needed.
  • Compose provider checkpoint hooks so Undo resolves through the provider that owns the tool-call checkpoint, while preserving legacy Big Sky checkpoint messages.

Why are these changes being made?

  • A requested edit summary describes what the model asked the client to do, not whether the editor actually changed. Rendering it before execution could make a no-op look successful.
  • Gutenberg sessions without the Big Sky rewrite ability use wpcom/update-block-content and render its summary directly. The old schema only asked for a brief description, so a real stuffs to stuff correction could still show Corrected spelling and grammar in the selected paragraph.
  • On editor surfaces with multiple providers, Agents Manager kept only the first checkpoint hook. A later provider could apply an edit but its checkpoint could not be found, so Updated and Undo did not render.
  • This keeps outcome rendering tied to explicit tool results instead of guessing from generated prose. The paired WPCOM prompt change remains responsible for clean grammar checks that do not invoke an edit tool.
  • Jetpack AI sidebar: scope picker Undo to what each picker can restore (FORNO-310) #112370 contains overlapping multi-provider checkpoint composition for picker Undo. Whichever PR lands second should rebase and keep one shared composition implementation.

Testing Instructions

  • Run:
    yarn test-packages packages/agents-manager/src/components/__tests__/orchestrator-chat.test.tsx packages/agents-manager/src/hooks/__tests__/use-checkpoint-action.test.ts packages/agents-manager/src/utils/__tests__/convert-tool-messages-to-components.test.ts packages/agents-manager/src/utils/__tests__/load-external-providers.test.ts packages/jetpack-ai-sidebar/src/index.test.ts --runInBand --no-watchman
    • 5 suites and 321 tests pass.
  • Run yarn workspace @automattic/jetpack-ai-sidebar typecheck.
  • Run focused ESLint, Stylelint, Prettier, and git diff --check for the changed files.
  • Run yarn workspace @automattic/agents-manager-app build.
  • Confirm the built sidebar provider contains concrete completed edit and no longer contains A brief user-friendly description of what was changed.
  • In the post editor, apply a selected-block grammar edit. Confirm the response names the exact correction, followed by one green Updated status and a working Undo; thumbs up/down and Copy appear on the next row.
  • Click Undo and confirm the block returns to its pre-edit content and the restored draft saves.
  • Submit a block edit whose explicit provider outcome is no-changes. Confirm No changes needed appears with no Undo.
  • Reload the conversation and confirm session-only Undo is not rendered as a dead action.

Pre-merge Checklist

  • Has the general commit checklist been followed? (PCYsg-hS-p2)
  • Have you written new tests for your changes?
  • Have you tested the feature in Simple (P9HQHe-k8-p2), Atomic (P9HQHe-jW-p2), and self-hosted Jetpack sites (PCYsg-g6b-p2)?
  • Have you checked for TypeScript, React or other console errors?
  • For UI changes, have you tested the affected components in dark mode?
  • Have you tested accessibility for your changes? Ensure the feature remains usable with various user agents (e.g., browsers), interfaces (e.g., keyboard navigation), and assistive technologies (e.g., screen readers) (PCYsg-S3g-p2).
  • Have you used memoizing on expensive computations? More info in Memoizing with create-selector and Using memoizing selectors and Our Approach to Data
  • Have we added the "[Status] String Freeze" label as soon as any new strings were ready for translation (p4TIVU-5Jq-p2)?
    • For UI changes, have we tested the change in various languages (for example, ES, PT, FR, or DE)? The length of text and words vary significantly between languages.
  • For changes affecting Jetpack: Have we added the "[Status] Needs Privacy Updates" label if this pull request changes what data or activity we track or use (p4TIVU-aUh-p2)?

Related

  • Big Sky PR 6233.
  • WPCOM PR 233020.

@kat3samsin kat3samsin added the [Status] String Freeze Add the [Status] String Freeze label to your PR to ensure new strings are translated before merging label Aug 5, 2026 — with ChatGPT Codex Connector
@a8ci18n

a8ci18n commented Aug 5, 2026

Copy link
Copy Markdown

This Pull Request is now available for translation here: https://translate.wordpress.com/deliverables/34662396

Some locales (Hebrew, Japanese) have been temporarily machine-translated due to translator availability. All other translations are usually ready within a few days. Untranslated and machine-translated strings will be sent for translation next Monday and are expected to be completed by the following Friday.

Thank you @kat3samsin for including a screenshot in the description! This is really helpful for our translators.

@kat3samsin kat3samsin changed the title Jetpack AI: show block edit outcomes with Undo (FORNO-451) Jetpack AI: show block edit outcomes with Undo Aug 5, 2026
@kat3samsin
kat3samsin requested a review from Copilot August 5, 2026 22:45
@matticbot matticbot added the [Status] Needs Review The PR is ready for review. This also triggers e2e canary tests and wp-desktop tests automatically. label Aug 5, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Updates Jetpack AI block-edit messaging and Agents Manager checkpoint handling so the UI shows only authoritative post-execution outcomes, with an “Updated” status + Undo for applied edits and a clear “No changes needed” for true no-ops. It also fixes multi-provider checkpoint composition so Undo resolves through the provider that owns the checkpoint.

Changes:

  • Jetpack sidebar update-block-content now emits structured updated / no-changes outcomes and stores restorable block snapshots keyed by tool call id.
  • Agents Manager tool-message rendering now prefers authoritative tool outcomes (and suppresses request-shaped/duplicate/prose messages accordingly).
  • Agents Manager now composes useCheckpoint hooks across providers and introduces a dedicated “Updated + Undo” action UI.

Reviewed changes

Copilot reviewed 14 out of 14 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
packages/jetpack-ai-sidebar/src/utils/block-actions.ts Treats true no-op block edits as successful without mutating the block.
packages/jetpack-ai-sidebar/src/index.ts Wraps update-block-content to produce structured outcomes and registers block snapshots for Undo via checkpoints.
packages/jetpack-ai-sidebar/src/index.test.ts Adds tool-provider tests for updated/no-changes outcomes and checkpoint behavior.
packages/agents-manager/src/utils/tool-message-utils.ts Adds block-edit tool id helpers and extracts structured updated / no-changes outcomes (with legacy fallback).
packages/agents-manager/src/utils/load-external-providers.ts Composes useCheckpoint across multiple providers so id-based lookups search all stores.
packages/agents-manager/src/utils/convert-tool-messages-to-components.ts Renders only authoritative block-edit outcomes, adds “✓ No changes needed”, and suppresses trailing prose/duplicates.
packages/agents-manager/src/utils/tests/load-external-providers.test.ts Tests composed checkpoint hook behavior across multiple providers.
packages/agents-manager/src/hooks/use-checkpoint-action.ts Adds resolved “Updated + Undo” action UI and derives checkpoint ids from structured outcomes/tool call ids.
packages/agents-manager/src/hooks/tests/use-checkpoint-action.test.ts New tests validating resolved Undo action behavior and outcome-based visibility.
packages/agents-manager/src/components/resolved-edit-action.tsx New component rendering “Updated” status + Undo button with disable/retry behavior.
packages/agents-manager/src/components/orchestrator-chat/index.tsx Precomputes/dedupes checkpoint actions for streaming/synthetic messages and removes stale checkpoint actions.
packages/agents-manager/src/components/agent-dock/chat-ui.scss Styles the new resolved edit action UI.
packages/agents-manager/src/components/tests/orchestrator-chat.test.tsx Adjusts mocks and adds coverage for deduped checkpoint actions on synthetic streaming messages.
Suppressed comments (1)

packages/jetpack-ai-sidebar/src/index.test.ts:2999

  • This test enables fake timers (jest.useFakeTimers()) but doesn’t restore real timers afterward, which can leak fake-timer state into subsequent tests in this file.
			expect( checkpoint.hasCheckpoint( 'call-no-block-change' ) ).toBe( false );
		} );

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread packages/jetpack-ai-sidebar/src/index.ts
Comment thread packages/agents-manager/src/components/agent-dock/chat-ui.scss
Comment thread packages/jetpack-ai-sidebar/src/index.test.ts

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 14 out of 14 changed files in this pull request and generated no new comments.

Suppressed comments (2)

packages/jetpack-ai-sidebar/src/index.ts:688

  • For a true no-op (outcome === 'no-changes'), this still prefers input.summary as the message. That summary describes the requested edit, not the authoritative outcome, and can cause the tool result payload to say e.g. “Proofread…” even when no changes were applied. It should ignore summary for no-op outcomes and emit a consistent no-change message.
	let message = typeof input?.summary === 'string' ? input.summary.trim() : '';
	if ( ! message ) {
		message =
			outcome === 'updated'
				? __( 'Updated the selected block.', __i18n_text_domain__ )

packages/agents-manager/src/utils/convert-tool-messages-to-components.ts:186

  • followsTerminalApplyBlockEditsOutcome returns false on the first JSON parse failure while scanning backward. If an agent emits multiple consecutive prose messages after a terminal block-edit outcome, only the first one will be suppressed; later ones will slip through because the previous prose isn’t JSON and the scan stops early. On parse errors, this should continue scanning until it finds a relevant tool message or a user boundary.
				earlierData.data?.followUpTasks !== true
			);
		} catch ( _error ) {
			return false;
		}

@kat3samsin
kat3samsin marked this pull request as ready for review August 6, 2026 23:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

[Status] Needs Review The PR is ready for review. This also triggers e2e canary tests and wp-desktop tests automatically. [Status] String Freeze Add the [Status] String Freeze label to your PR to ensure new strings are translated before merging

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants